<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
    <title>DIDIFight</title>
	<#include "common/header.ftl"/>
    <script type="text/javascript" src="/js/plugins/jquery.form.js"></script>
    <script type="text/javascript" src="/js/plugins/jquery-validation/jquery.validate.js"></script>
    <script type="text/javascript">
        $(function () {
            $(function () {
                //点击查询按钮
                $("#query").click(function () {
                    $("#searchForm").submit();
                });
                //点击删除按钮
                $(".delete_Btn").click(function () {
                    $.get("/locationBlacklistDelete", {id: $(this).data("id")}, function (data) {
                            if (data.success) {
                                $("#searchForm").submit();
                            } else {
                                $.messager.popup(data.msg);
                            }
                        },"json"
                    )
                })

                //点击新增按钮
                $("#addLocationBlacklistBtn").click(function () {
                    $("#editForm").clearForm(true);
                    $("#menuModal").modal("show");
                });
                //点击保存按钮
                $("#saveBtn").click(function () {
                    $("#editForm").ajaxSubmit({
                        datatype: "json",
                        success: function (data) {
                            if (data.success) {
                                $("#currentPage").val(1);
                                $("#searchForm").submit();
                            } else {
                                $.messager.popup(data.msg);
                            }
                        }
                    })
                });
                //点击修改按钮
                $(".edit_Btn").click(function () {
                    $("#editForm").clearForm(true);
                    //数据回显
                    var data = $(this).data("json");
                    $("#id").val(data.id);
                    $("#keyword").val(data.keyword);
                    $("#menuModal").modal("show");
                })
            });
        });
    </script>
</head>

<body>
<div class="container">
		<#include "common/top.ftl"/>
    <div class="row">
        <div class="col-sm-3">
        <#assign currentMenu = "locationBlacklist" />
        <#include "common/menu.ftl" />
        </div>
        <div class="col-sm-9">
            <div class="page-header">
                <center>
                    <h3>地点黑名单管理</h3>
                </center>
            </div>
            <div class="row">
                <!-- 提交分页的表单 -->
                <form id="searchForm" class="form-inline" method="post" action="/locationBlacklist">
                    <input type="text" class="form-control" value="${qo.keyword!''}" name="keyword"
                           placeholder="KEYWORD" style="background-color: #eefbbb">
                    <div class="form-group">
                        <button id="query" type="button" class="btn btn-success"><i class="icon-search"></i> 查询</button>
                        <a href="javascript:void(-1);" class="btn btn-success" id="addLocationBlacklistBtn">添加地址</a>
                    </div>
                </form>
            </div>
            <div class="row">
                <table class="table">
                    <thead>
                    <tr>
                        <th>KEYWORD</th>
                    </tr>
                    </thead>
                    <tbody>
						<#list list as vo>
                        <tr>
                            <td>${vo.keyword!''}</td>
                            <td>
                                <a href="javascript:void(-1);" class="edit_Btn" data-json='${vo.jsonString!''}'>修改</a>&nbsp;
                                <a href="javascript:void(-1);" class="delete_Btn" data-id="${vo.id}">删除</a>
                            </td>
                        </tr>
                        </#list>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>

<div id="menuModal" class="modal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">编辑/增加</h4>
            </div>
            <div class="modal-body">
                <form id="editForm" class="form-horizontal" method="post" action="/locationBlacklistUpdate"
                      style="margin: -3px 118px">
                    <input id="id" type="hidden" name="id" value=""/>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">KEYWORD</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="keyword" name="keyword" placeholder="KEYWORD">
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <a href="javascript:void(0);" class="btn btn-success" id="saveBtn" aria-hidden="true">保存</a>
                <a href="javascript:void(0);" class="btn" data-dismiss="modal" aria-hidden="true">关闭</a>
            </div>
        </div>
    </div>
</div>
</body>
</html>